package operation_system.philosopher_eating;


//奇数拿左边，偶数拿右边
public class AImpl {
    public static final int SIZE = 5;


    public static void main(String[] args) {

        Object[] objects = new Object[SIZE];
        for (int i = 0; i < SIZE; i++) {
            objects[i] = new Object();
        }
        for (int i = 0; i < SIZE; i++) {
            AEatAndThink AEatAndThink;
            if (i < SIZE - 1) {
                if (i % 2 == 0) {
                    //右
                    AEatAndThink = new AEatAndThink(objects[i + 1], objects[i]);

                } else {
                    //左
                    AEatAndThink = new AEatAndThink(objects[i], objects[i + 1]);

                }
                new Thread(AEatAndThink).start();
            } else {
                AEatAndThink = new AEatAndThink(objects[i], objects[0]);
            }
            new Thread(AEatAndThink).start();

        }

    }
}
